Skip to content

Conversation

@ingDIY
Copy link
Contributor

@ingDIY ingDIY commented Jun 20, 2025

fixed compiler warnings for uninitialized vars
fixed compiler warnings for unused variables

Summary by CodeRabbit

  • Bug Fixes

    • Improved stability of the Particle Fireworks effect by ensuring internal variables are properly initialized, reducing the risk of unexpected behavior.
  • Refactor

    • Enhanced configuration handling to only process EEPROM and interface settings when relevant features (such as MQTT or HueSync) are enabled, optimizing performance and resource usage.

ingDIY added 3 commits June 20, 2025 13:53
fixed warning: vars may be used uninitialized in this function
fixed compiler warning: var is unused
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 20, 2025

Walkthrough

The changes update variable initialization and conditional compilation in two source files. In wled00/FX.cpp, local variables in the mode_particlefireworks() function are explicitly initialized, and one unused variable is removed. In wled00/cfg.cpp, conditional compilation is applied to EEPROM, MQTT, and HueSync-related configuration code, refining when certain JSON objects and logic are included.

Changes

Files Change Summary
wled00/FX.cpp Explicitly initializes several local variables in mode_particlefireworks(); removes unused speedvariation.
wled00/cfg.cpp Adds conditional compilation for EEPROM, MQTT, and HueSync config code; reduces unnecessary JSON object creation.

Possibly related PRs

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
wled00/FX.cpp (1)

7862-7863: Prefer fixed-width types and consistent sizing for angle variables
Using unsigned for angleincrement is ambiguous; prefer uint16_t (or another exact-width type) for consistency with angle.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 05557ca and 412b994.

📒 Files selected for processing (2)
  • wled00/FX.cpp (1 hunks)
  • wled00/cfg.cpp (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: wled_build / Build Environments (esp32c3dev)
  • GitHub Check: wled_build / Build Environments (esp32_wrover)
  • GitHub Check: wled_build / Build Environments (esp32dev_V4)
  • GitHub Check: wled_build / Build Environments (usermods)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_8MB_opi)
  • GitHub Check: wled_build / Build Environments (esp32s3_4M_qspi)
  • GitHub Check: wled_build / Build Environments (esp32dev)
  • GitHub Check: wled_build / Build Environments (lolin_s2_mini)
  • GitHub Check: wled_build / Build Environments (esp01_1m_full_compat)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_16MB_opi)
  • GitHub Check: wled_build / Build Environments (esp32_eth)
  • GitHub Check: wled_build / Build Environments (esp01_1m_full_160)
  • GitHub Check: wled_build / Build Environments (esp01_1m_full)
  • GitHub Check: wled_build / Build Environments (nodemcuv2_160)
  • GitHub Check: wled_build / Build Environments (esp8266_2m)
  • GitHub Check: wled_build / Build Environments (nodemcuv2_compat)
  • GitHub Check: wled_build / Build Environments (esp8266_2m_compat)
  • GitHub Check: wled_build / Build Environments (nodemcuv2)
  • GitHub Check: wled_build / Build Environments (esp8266_2m_160)
  • GitHub Check: wled_build / Test cdata.js
🔇 Additional comments (4)
wled00/cfg.cpp (3)

778-783: LGTM - Appropriate conditional compilation for EEPROM features.

The conditional compilation correctly guards EEPROM-related function calls when EEPROM support is disabled, preventing compilation of unused code.


1275-1277: Good optimization - conditional interfaces object creation.

The conditional compilation correctly avoids creating the interfaces JsonObject when both MQTT and HueSync features are disabled, reducing memory usage and processing overhead.


1319-1321: Consistent conditional compilation for serialization.

The same conditional compilation pattern is correctly applied to the serialization path, maintaining consistency with the deserialization changes.

wled00/FX.cpp (1)

7859-7859: Good suppression of unused-variable warnings and defined initialization
Initializing speed to a safe default and marking it [[maybe_unused]] cleanly resolves the compiler warning.

Comment on lines +789 to +791
#ifdef WLED_ADD_EEPROM_SUPPORT
success = readObjectFromFile(s_cfg_json, nullptr, pDoc);
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Critical logic error: cfg.json reading should not depend on EEPROM support.

The readObjectFromFile call reads from the filesystem (/cfg.json), not from EEPROM. Making this conditional on WLED_ADD_EEPROM_SUPPORT means the configuration file won't be read when EEPROM support is disabled, causing deserializeConfig() to operate on an empty JsonObject.

This breaks the core configuration loading functionality when EEPROM support is compiled out.

-  #ifdef WLED_ADD_EEPROM_SUPPORT
   success = readObjectFromFile(s_cfg_json, nullptr, pDoc);
-  #endif
🤖 Prompt for AI Agents
In wled00/cfg.cpp around lines 789 to 791, remove the #ifdef
WLED_ADD_EEPROM_SUPPORT conditional around the readObjectFromFile call so that
the configuration file is always read regardless of EEPROM support. This ensures
deserializeConfig() receives the correct JsonObject from the filesystem and
prevents loading failures when EEPROM support is disabled.

// variables for circular explosions
[[maybe_unused]] int32_t speed, currentspeed, speedvariation, percircle;
[[maybe_unused]] int32_t speed = 2; // just init to min value
[[maybe_unused]] int32_t currentspeed, percircle;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Initialize or remove uninitialized variables currentspeed and percircle
These variables are declared uninitialized and marked [[maybe_unused]], which risks undefined behavior if they later become used. Either initialize them explicitly (e.g., = 0) or remove them if truly unused.

🤖 Prompt for AI Agents
In wled00/FX.cpp at line 7860, the variables currentspeed and percircle are
declared but uninitialized and marked [[maybe_unused]], which can lead to
undefined behavior if used later. To fix this, either initialize both variables
explicitly to zero or another appropriate default value, or remove their
declarations entirely if they are not used anywhere in the code.

@DedeHai
Copy link
Collaborator

DedeHai commented Jun 20, 2025

thanks for the input.
I do not like to increase code size just to shut up the compiler though.

@ingDIY
Copy link
Contributor Author

ingDIY commented Jun 20, 2025

thanks for the input. I do not like to increase code size just to shut up the compiler though.

I don't think that the code will be bigger just because some var is initialized and the are better managed compile masks

@DedeHai
Copy link
Collaborator

DedeHai commented Jun 20, 2025

I don't think that the code will be bigger just because some var is initialized and the are better managed compile masks

try it.
the init values need to be stored somewhere.

@ingDIY
Copy link
Contributor Author

ingDIY commented Jun 20, 2025

I tryed, and the compile output is even smaller. I am comparing the current PR with the main branch:
Immagine 2025-06-20 173819

"a", "b" and "c" are my custom builds.

Initializing variables is good practice to avoid warnings about uninitialized use, which can lead to undefined behavior.

What do you think about it?
Thanks!

@DedeHai
Copy link
Collaborator

DedeHai commented Jun 20, 2025

Initializing variables is good practice to avoid warnings about uninitialized use, which can lead to undefined behavior.
that is true but not initializing variables that are for sure initialized later serves no purpose.

I do see the sum of your commits saves on flash, did not investigate why yet. But the changes you made to FX.cpp which is adding technically unneeded inits uses a few bytes of extra flash.

@ingDIY
Copy link
Contributor Author

ingDIY commented Jun 20, 2025

Initializing variables is good practice to avoid warnings about uninitialized use, which can lead to undefined behavior.
that is true but not initializing variables that are for sure initialized later serves no purpose.

I do see the sum of your commits saves on flash, did not investigate why yet. But the changes you made to FX.cpp which is adding technically unneeded inits uses a few bytes of extra flash.

Dear @DedeHai , technically yes, initializing variables requires flash but, in this case, we are talking about 6 or 8 bytes that compared to 4MB of flash is a very small increase.

Anyway I don't want to convince anyone about this good coding practice.😌

Anyway if we talk about flash reduction, this PR saves about 600 bytes, feel free to check it, please!

Thanks for collaborating in this project😁

@DedeHai
Copy link
Collaborator

DedeHai commented Jun 21, 2025

the reason this PR saves flash: it removes config and breaks everything.

@DedeHai DedeHai closed this Jun 21, 2025
@ingDIY ingDIY deleted the patch-3 branch December 7, 2025 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants